/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.javanile.me.chessengine;

/**
 *
 * @author cicciodarkast
 */
public class Constants {
    
	public static final String  START_POSITION = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
	public static final String  TEST_POSITION_1 = "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1";
	public static final String  TEST_POSITION_2 = "r1bqkbnr/1ppp1ppp/p1n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQkq";
	
	public static final int[]	PIECE_ID = {
		0,0,0,0,0,0,0,0,0,0,0
	};
		
	public static final int	// Squares
		A8=12*2+2, B8=12*2+3, C8=12*2+4, D8=12*2+5, E8=12*2+6, F8=12*2+7, G8=12*2+8, H8=12*2+9,
		A7=12*3+2, B7=12*3+3, C7=12*3+4, D7=12*3+5, E7=12*3+6, F7=12*3+7, G7=12*3+8, H7=12*3+9,
		A6=12*4+2, B6=12*4+3, C6=12*4+4, D6=12*4+5, E6=12*4+6, F6=12*4+7, G6=12*4+8, H6=12*4+9,
		A5=12*5+2, B5=12*5+3, C5=12*5+4, D5=12*5+5, E5=12*5+6, F5=12*5+7, G5=12*5+8, H5=12*5+9,
		A4=12*6+2, B4=12*6+3, C4=12*6+4, D4=12*6+5, E4=12*6+6, F4=12*6+7, G4=12*6+8, H4=12*6+9,
		A3=12*7+2, B3=12*7+3, C3=12*7+4, D3=12*7+5, E3=12*7+6, F3=12*7+7, G3=12*7+8, H3=12*7+9,
		A2=12*8+2, B2=12*8+3, C2=12*8+4, D2=12*8+5, E2=12*8+6, F2=12*8+7, G2=12*8+8, H2=12*8+9,
		A1=12*9+2, B1=12*9+3, C1=12*9+4, D1=12*9+5, E1=12*9+6, F1=12*9+7, G1=12*9+8, H1=12*9+9;
	
	public static final int[] BOARD = {
		A8,B8,C8,D8,E8,F8,G8,H8,
		A7,B7,C7,D7,E7,F7,G7,H7,
		A6,B6,C6,D6,E6,F6,G6,H6,
		A5,B5,C5,D5,E5,F5,G5,H5,
		A4,B4,C4,D4,E4,F4,G4,H4,
		A3,B3,C3,D3,E3,F3,G3,H3,
		A2,B2,C2,D2,E2,F2,G2,H2,
		A1,B1,C1,D1,E1,F1,G1,H1,0
	};
		
	public static final int[] BOARD0 = {
		E2,D2,G1,B1,F1,C1,D1,E1,
		A8,B8,C8,D8,E8,F8,G8,H8,
		A7,B7,C7,D7,E7,F7,G7,H7,
		A6,B6,C6,D6,E6,F6,G6,H6,
		A5,B5,C5,D5,E5,F5,G5,H5,
		A4,B4,C4,D4,E4,F4,G4,H4,
		A3,B3,C3,D3,E3,F3,G3,H3,
		A2,B2,C2,F2,G2,H2,
		A1,H1,0
	};
		
	public static final int[] BOARD1 = {
		E7,D7,B8,G8,C8,F8,D8,E8,
		A7,B7,C7,F7,G7,H7,A8,H8,
		A6,B6,C6,D6,E6,F6,G6,H6,
		A5,B5,C5,D5,E5,F5,G5,H5,
		A4,B4,C4,D4,E4,F4,G4,H4,
		A3,B3,C3,D3,E3,F3,G3,H3,
		A2,B2,C2,D2,E2,F2,G2,H2,
		A1,B1,C1,D1,E1,F1,G1,H1,0
	};
	
	public static final int		COLOR = 8;
	public static final int		ISLONG = 64;
	public static final int		ISPAWN = 64+8;
	public static final int		ABILITY = 128;
	public static final int		STARTABILITY = 128+8;
	public static final int		PAWNDOUBLE = 64+4;
	
	public static final int[]	MAP = {
		/*  0:*/ -13,-12,1,-1,		12,11,-11,13,	1,-1,12,-12,	0,0,0,0,
		/* 16:*/ -25,-23,-10,-14,	25,23,10,14,	0,0,0,0,		0,0,0,0,
		/* 32:*/ -11,11,-13,13,		0,0,0,0,		0,0,0,0,		0,0,0,0,
		/* 48:*/ 0,0,0,0,			0,0,0,0,		0,0,0,0,		0,0,0,0,
		
		/* 64:*/ 0,0,9,3,			0,8,0,0,		0,0,1,12,		0,0,8,0,
		/* 80:*/ 7,11,10,1,			0,0,1,0,		1,1,1,0,		0,0,0,0,
		/* 96:*/ 0,0,3,0,			0,0,0,0,		0,0,-1,6,		0,0,2,0,
		/*112:*/ 1,5,4,-1,			0,0,-1,0,		-1,-1,-1,0,		0,0,0,0,
		
		/*128:*/ 0,0,1,0,			0,0,0,0,		0,0,0,2,		0,0,2,0,
		/*  0:*/ 0,1,1,0,			0,0,0,0,		1,0,0,0,		0,0,0,0,
		/*  0:*/ 0,0,1,0,			0,0,0,0,		0,0,0,2,		0,0,2,0,
		/*  0:*/ 0,1,1,0,			0,0,0,0,		1,0,0,0,		0,0,0,0,
		
		/*  0:*/ 0,0,4,0,			0,0,0,0,		0,0,32,0,		0,0,0,0,
		/*  0:*/ 0,8,4,0,			0,0,16,0,		0,0,8,0,		0,0,0,0,
		/*  0:*/ 0,0,4,0,			0,0,0,0,		0,0,32,0,		0,0,0,0,
		/*  0:*/ 0,8,4,0,			0,0,16,0,		0,0,8,0,		0,0,0,0		
	};
	
	
	
    public static final int     P_NONE  = 0;
    public static final int     P_WP    = 1;
    public static final int     P_WN    = 2;
    public static final int     P_WB    = 3;
    public static final int     P_WR    = 4;
    public static final int     P_WQ    = 5;
    public static final int     P_WK    = 6;    
    public static final int     P_BP    = 7;
    public static final int     P_BN    = 8;
    public static final int     P_BB    = 9;
    public static final int     P_BR    = 10;
    public static final int     P_BQ    = 11;
    public static final int     P_BK    = 12;
        
    public static final int     MK_WPS  = 0;
    public static final int     MK_WPD  = 1;
    public static final int     MK_WPCE = 2;
    public static final int     MK_WPCW = 3;
        
    public static final int     MK_BPS  = 4;
    public static final int     MK_BPD  = 5;
    public static final int     MK_BPCE = 6;
    public static final int     MK_BPCW = 7;
    
    public static final int     MK_LNN = 8;
    public static final int     MK_LNE = 9;
    public static final int     MK_LNW = 10;    
    public static final int     MK_LSS = 11;
    public static final int     MK_LSE = 12;
    public static final int     MK_LSW = 13;    
    public static final int     MK_LEE = 14;
    public static final int     MK_LWW = 15;
        
    public static final int     MK_SIMPLE = 10000 + 1;
 
	public static final int		MK_PAWN_SIMPLE		= 1000;
	public static final int		MK_PAWN_DOUBLE		= 1001;
	public static final int		MK_PAWN_ENPASSANT	= 1002;
	
	public static final int		MK_SHORT_CASTLING = 9000;
	public static final int		MK_LONG_CASTLING = 9001;
	
    public static final int[][] _DELTA = {
        /*MK_WPS:*/ {-1,0},
        /*MK_WPD:*/ {-2,0},
        /*MK_WPCE:*/{-1,1},
        /*MK_WPCW:*/{-1,-1},        
        /*MK_BPS:*/ {1,0},
        /*MK_BPD:*/ {2,0},
        /*MK_BPCE:*/{1,1},
        /*MK_BPCW:*/{1,-1},
        /*MK_LNN:*/ {-1,0},
        /*MK_LNE:*/ {-1,1},
        /*MK_LNW:*/ {-1,-1},
        /*MK_LSS:*/ {1,0},
        /*MK_LSE:*/ {1,1},
        /*MK_LSW:*/ {1,-1},
        /*MK_LEE:*/ {0,1},
        /*MK_LWW:*/ {0,-1}    
    };
    
    public static final int[][] ABILITIES = {
        /*P_NONE*/  {},
        /*P_WP*/    {},
        /*P_WN*/    {},
        /*P_WB*/    {MK_LNE,MK_LNW,MK_LSE,MK_LSW},
        /*P_WR*/    {MK_LNN,MK_LWW,MK_LEE,MK_LSS},
        /*P_WQ*/    {MK_LNN,MK_LWW,MK_LEE,MK_LSS,MK_LNE,MK_LNW,MK_LSE,MK_LSW},
        /*P_WK*/    {},
        /*P_BP*/    {},
        /*P_BN*/    {},
        /*P_BB*/    {MK_LNE,MK_LNW,MK_LSE,MK_LSW},
        /*P_BR*/    {MK_LNN,MK_LWW,MK_LEE,MK_LSS},
        /*P_BQ*/    {MK_LNN,MK_LWW,MK_LEE,MK_LSS,MK_LNE,MK_LNW,MK_LSE,MK_LSW},
        /*P_BK*/    {}        
    };
    
    public static final int[] _VALUE = {
        /*P_NONE*/  0,
        /*P_BP*/   -100,
        /*P_BN*/   -290,
        /*P_BB*/   -300,
        /*P_BR*/   -500,
        /*P_BQ*/   -900,
        /*P_BK*/   -100000,
		/*P_WP*/    100,
        /*P_WN*/    290,
        /*P_WB*/    300,
        /*P_WR*/    500,
        /*P_WQ*/    900,
        /*P_WK*/    100000        
    };
    
	public static final int[] SQUARE_VALUE = {
		0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,1,1,1,1,1,1,1,1,0,0,
		0,0,1,2,2,2,2,2,2,1,0,0,
		0,0,1,2,5,5,5,5,2,1,0,0,
		0,0,1,2,5,9,9,5,2,1,0,0,
		0,0,1,2,5,9,9,5,2,1,0,0,
		0,0,1,2,5,5,5,5,2,1,0,0,
		0,0,1,2,2,2,2,2,2,1,0,0,
		0,0,1,1,1,1,1,1,1,1,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0
	};
	
    public static final int[]   RULE = {};
    
    public static int[] DELTA(char p, int mk) {
        switch(p) {
            case 'p':return _DELTA[mk];         
            case 'n':return _DELTA[mk];
            case 'b':return _DELTA[mk];         
            case 'r':return _DELTA[mk];
            case 'q':return _DELTA[mk];         
            case 'k':return _DELTA[mk];
            case 'P':return _DELTA[mk];         
            case 'N':return _DELTA[mk];
            case 'B':return _DELTA[mk];         
            case 'R':return _DELTA[mk];
            case 'Q':return _DELTA[mk];         
            case 'K':return _DELTA[mk];                
        }
        return null;
    }
    
    public static int[] GAMMA(char p) {
        switch(p) {
            case 'p':return ABILITIES[P_BP];         
            case 'n':return ABILITIES[P_BN];         
            case 'b':return ABILITIES[P_BB];         
            case 'r':return ABILITIES[P_BR];         
            case 'q':return ABILITIES[P_BQ];         
            case 'k':return ABILITIES[P_BK];         
            case 'P':return ABILITIES[P_WP];         
            case 'N':return ABILITIES[P_WN];         
            case 'B':return ABILITIES[P_WB];         
            case 'R':return ABILITIES[P_WR];         
            case 'Q':return ABILITIES[P_WQ];         
            case 'K':return ABILITIES[P_WK];               
        }
        return null;
    }
    
    public static int VALUE(char p) {
        switch(p) {
            case 'p':return _VALUE[P_BP];         
            case 'n':return _VALUE[P_BN];         
            case 'b':return _VALUE[P_BB];         
            case 'r':return _VALUE[P_BR];         
            case 'q':return _VALUE[P_BQ];         
            case 'k':return _VALUE[P_BK];         
            case 'P':return _VALUE[P_WP];         
            case 'N':return _VALUE[P_WN];         
            case 'B':return _VALUE[P_WB];         
            case 'R':return _VALUE[P_WR];         
            case 'Q':return _VALUE[P_WQ];         
            case 'K':return _VALUE[P_WK];               
        }
        return 0;
    }
	
	public final static int DEBUG_GETMOVES = 1;
}
